package com.imooc.miaosha.exception;

import com.imooc.miaosha.result.CodeMsg;
import com.imooc.miaosha.result.ResultEnums;
import lombok.Getter;

/**
 * 模块描述: <br>
 * (全局异常方法类)
 *
 * @Author: Mr. xyb
 * @Date: 2019/4/17 10:03
 * @since: 1.8.0
 * @version: 1.0.0
 */
@Getter
public class GlobalException extends RuntimeException {

    private CodeMsg codeMsg;

    public GlobalException(CodeMsg codeMsg) {
        super(codeMsg.toString());
        this.codeMsg = codeMsg;
    }

    public GlobalException(ResultEnums resultEnums) {
        super(resultEnums.toString());
        CodeMsg codeMsg = new CodeMsg(resultEnums.getCode(), resultEnums.getMsg());
        this.codeMsg = codeMsg;
    }

}
